﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using CoreEx.Services;
using LinFu.IoC.Interfaces;
using LinFu.IoC;

namespace CoreEx.Common.Reflection
{
    public static class PropertyInfoExtensions
    {
        private static IServiceContainer _serviceContainer;
        private static IBackingFieldRepository _backingFieldRepository;

        static PropertyInfoExtensions()
        {
            _serviceContainer = ServiceLocator.Container;
            _backingFieldRepository = _serviceContainer.GetService<IBackingFieldRepository>();
            
        }

        public static FieldInfo GetBackingField(this PropertyInfo propertyInfo)
        {
            return _backingFieldRepository.GetField(propertyInfo);
        }

    }
}
